use std::thread;
use std::time::Duration;
use wang_utils::queue::SimpleQueue;

fn main() {
    println!("Hello, world!");

    // 初始化队列
    let queue = SimpleQueue::builder()
        .add_listen("demo1", listen_demo1)
        .add_listen("demo2", listen_demo2);

    for _ in 0..10 {
        queue.send("demo1", Message::I32(1));
        queue.send("demo2", Message::String(String::from("Hello, world!")));
    }
    // 这里怎么能锁定进程，等待15秒后再继续
    thread::sleep(Duration::from_secs(15));
}
#[derive(Debug)]
pub enum Message {
    I32(i32),
    String(String),
}
// 测试接收消息
pub fn listen_demo1(message: Message) {
    println!("Listening on demo1:{:?}", message);
    thread::sleep(Duration::from_millis(1000));
    println!("Listening on demo1 done");
}
pub fn listen_demo2(message: Message) {
    println!("Listening on demo2:{:?}", message);
    thread::sleep(Duration::from_millis(1000));
    println!("Listening on demo2 done");
}
